package com.ruoyi.Gun.service.impl;

import com.ruoyi.Gun.domain.Gun;
import com.ruoyi.Gun.mapper.GunMapper;
import com.ruoyi.Gun.service.GunService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GunServiceImpl implements GunService{

    @Autowired
    GunMapper mapper;

    @Override
    public List<Gun> GunList(Gun gun) {
        return mapper.GunList(gun);
    }

    @Override
    public List<Gun> selectGun(String gun) {
        return mapper.selectGun(gun);
    }

    @Override
    public int addGun(Gun gun) {
        return mapper.addGun(gun);
    }

    @Override
    public int updateGun(Gun gun) {
        return mapper.updateGun(gun);
    }

    @Override
    public int deleteGun(int id) {
        return mapper.deleteGun(id);
    }

    private static Logger log = LoggerFactory.getLogger(GunServiceImpl.class);

    @Override
    public List<Gun> selectGun2(Gun gun) {
        List<Gun> result = mapper.selectGun2(gun);
        if (result.size() <= 0) {
            log.error("没有查询到任何枪械");
        }else {
            log.info("查询到了枪械，查询到的是：" + result.get(0).getName());
        }
        return result;
    }
}
